package com.ikangtai.shecare.common.baseView.recordButtonView;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;

import com.ikangtai.shecare.R;
import com.ikangtai.shecare.main.RecordFragment;

/**
 * Created by Administrator on 2016/1/20.
 */
public class RecordSelectCopulationButton extends RecordSelectButton{

    private Context context;
    public static final int RECORD_COPULATION_SELECT_WHITE_BACKGROUND_COLOR = 0;
    public static final int RECORD_COPULATION_SELECT_PURPLE_BACKGROUND_COLOR = 1;
    public static final String RecordSelectCopulationButtonType="COPULATION";

    public RecordSelectCopulationButton(Context context){
        super(context);
        this.context=context;
        setType(RecordSelectCopulationButtonType);
    }
    public RecordSelectCopulationButton(Context context, AttributeSet attrs){
        super(context,attrs);
        this.context=context;
       this.backgroundColor = RECORD_COPULATION_SELECT_WHITE_BACKGROUND_COLOR;
    }

    @Override
    public void setColor(int backGroundColor) {
        super.setColor(backGroundColor);
    }

    @Override
    public void clickAction(View view) {
        RecordSelectCopulationButton recordSelectCopulationYesButton;
        RecordSelectCopulationButton recordSelectCopulationNoBtn;
       if(null!=view){
           recordSelectCopulationYesButton=(RecordSelectCopulationButton)view.findViewById(R.id.record_copulation_btn_yes);
           recordSelectCopulationNoBtn=(RecordSelectCopulationButton)view.findViewById(R.id.record_copulation_btn_no);

        if(backgroundColor == RECORD_COPULATION_SELECT_WHITE_BACKGROUND_COLOR||backgroundColor == RECORD_COPULATION_SELECT_PURPLE_BACKGROUND_COLOR){
            backgroundColor = RECORD_COPULATION_SELECT_PURPLE_BACKGROUND_COLOR;
            if(this.getId()==recordSelectCopulationYesButton.getId()){
                RecordFragment.copulationHaveSex= 1;
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_pressed));
                this.setTextColor(Color.WHITE);
                recordSelectCopulationNoBtn.setColor(RECORD_COPULATION_SELECT_WHITE_BACKGROUND_COLOR);
                recordSelectCopulationNoBtn.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_default));
                recordSelectCopulationNoBtn.setTextColor(getResources().getColor(R.color.conpulation_color));}

            if(this.getId()==recordSelectCopulationNoBtn.getId()){
                RecordFragment.copulationHaveSex= 0;
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_pressed));
                this.setTextColor(Color.WHITE);
                recordSelectCopulationYesButton.setColor(RECORD_COPULATION_SELECT_WHITE_BACKGROUND_COLOR);
                recordSelectCopulationYesButton.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_default));
                recordSelectCopulationYesButton.setTextColor(getResources().getColor(R.color.conpulation_color));
            }

        }
       }
    }

}
